﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace Sakura.Games.StgFramework
{
	using Res = Properties.Resources;

	/// <summary>
	/// 表示一个带有标识的项目。
	/// </summary>
	[Serializable]
	public class IdentifiedItem : BindableBase , IKeyedItem<string>
	{
		/// <summary>
		/// 项目的标识。
		/// </summary>
		private string _Id;

		/// <summary>
		/// 获取或设置项目的标识。
		/// </summary>
		public string Id
		{
			get
			{
				return _Id;
			}
			set
			{
				_Id = value;
				this.OnPropertyChanged("Id");
			}
		}

		/// <summary>
		/// 获得对象指定列的错误信息。
		/// </summary>
		/// <param name="columnName">要获取的错误的列。</param>
		/// <returns>该列的错误信息。</returns>
		protected override string GetError(string columnName)
		{
			switch (columnName)
			{
				case "Id":
					if (string.IsNullOrWhiteSpace(columnName))
					{
						return Res.ExIdCanNullBeEmpty;
					}
					break;
			}

			return base.GetError(columnName);
		}

		#region 事件封装


		#endregion

		string IKeyedItem<string>.Key
		{
			get
			{
				return this.Id;
			}
		}

		event CancelEventHandler IKeyedItem<string>.KeyChanging
		{
			add
			{
				throw new NotImplementedException();
			}
			remove
			{
				throw new NotImplementedException();
			}
		}

		event EventHandler IKeyedItem<string>.KeyChanged
		{
			add
			{
				throw new NotImplementedException();
			}
			remove
			{
				throw new NotImplementedException();
			}
		}
	}
}
